package com.huwaiwai.aqs.park;

import java.util.concurrent.locks.LockSupport;

/**
 * Created by hww on 2018/6/5 下午5:14.
 */
public class ParkAndInterrupted extends Thread {
    /**
     * When an object implementing interface <code>Runnable</code> is used
     * to create a thread, starting the thread causes the object's
     * <code>run</code> method to be called in that separately executing
     * thread.
     * <p>
     * The general contract of the method <code>run</code> is that it may
     * take any action whatsoever.
     *
     * @see Thread#run()
     */
    @Override
    public void run() {
        for (;;) {
            System.out.println("子线程挂起");
            long start = System.currentTimeMillis();
            LockSupport.park(this);
            System.out.println("子线程释放time=" + (System.currentTimeMillis() - start));
        }
    }
}
